// PicLibrary.h: interface for the CPicLibrary class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PICLIBRARY_H__F1B62A19_95B2_430B_821C_1549D9E43128__INCLUDED_)
#define AFX_PICLIBRARY_H__F1B62A19_95B2_430B_821C_1549D9E43128__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


#include "CXIMAGE\CXIMAGE\ximage.h"
#include <afxtempl.h>


#define PICTURE_OK  1
#define PICTURE_ERROR  2
#define PICTURE_NOTFOUND  3

class CPicLibrary  
{
public:
	void PaintTile(CxImage* pimg,CDC *pdc,CRect *ppos);
	void UnloadPicture(CString FileName);
	CxImage* FindPicture(CString FileName,int* pstatus );
	BOOL LoadPicture(CString FileName);

	class CPicListElement
	{	public:
		CxImage* pimg;
		CString FileName;
		CPicListElement() {pimg=NULL;}
		~CPicListElement() 
		{	if (pimg!=NULL)
			{	pimg->Destroy();
				delete pimg;
				pimg=NULL;
			}
		}
		void Load(CString FN)
		{	FileName=FN;
			CFileFind FF;
			if (FF.FindFile(FN))
			{	pimg=new CxImage();
				if (!pimg->Load(FileName,CXIMAGE_FORMAT_JPG))
				{	pimg->Destroy();
					delete pimg;
					pimg=NULL;
				}
			}

		}
	
	};

	typedef CTypedPtrList <CPtrList,CPicListElement*> CxImageList;

	void Paint(CDC* pdc,CRect* ppos,CString FileName,BOOL isStretch,BOOL isChain,BOOL isTile);
	CPicLibrary();
	virtual ~CPicLibrary();
	CxImageList m_piclist;

};

#endif // !defined(AFX_PICLIBRARY_H__F1B62A19_95B2_430B_821C_1549D9E43128__INCLUDED_)
